<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 判断数据类型的方法有哪些？
    // typeof  instanceof constructor  Object.prototype.toString.call()
    //  typeof 可以 准确的判断出简单数据类型  ，但是判断复杂数据类型返回的统一是Object 不能准确判断复杂数据类型
     
    let obj ={}
    let arr=[]
    let fn = ()=>{

    }
    let a = 1
    let b = 'abc'
    let flag = true
    let n = null
    let u = undefined
    let time = new Date()
    let reg = /^[1-5]/
    // console.log(typeof obj);
    // console.log(typeof arr);
    // console.log(typeof fn);


    // instanceof  能准确的判断出复杂数据类型 不能准确判断出简单数据类型   instanceof对null 和undefined无效  返回值是布尔值
    // console.log(a instanceof Number); //不能准确判断
    console.log(obj instanceof Object)
    console.log(arr instanceof Array)
    console.log(fn instanceof Function)
    // console.log(n instanceof null); //报错
    // console.log(u instanceof undefined);//报错


    // constructor
    // console.log(obj.__proto__.constructor == Object);
    console.log(obj.constructor == Object);
    console.log(obj);
    console.log(arr);
    console.log(arr.__proto__.constructor == Array);
    console.log(arr.constructor == Array);
    console.log(a.constructor == Number);
    // console.log(u.constructor == undefined);

    // null  和undfined 没有constructor函数  所以报错

    // Object.prototype.toString.call()


    console.log(Object.prototype.toString.call(a));

    console.log(Object.prototype.toString.call(b));
    console.log(Object.prototype.toString.call(u));
    console.log(Object.prototype.toString.call(n));
    console.log(Object.prototype.toString.call(arr));
    console.log(Object.prototype.toString.call(obj));
    console.log(Object.prototype.toString.call(fn));
    console.log(Object.prototype.toString.call(time));
    console.log(Object.prototype.toString.call(reg));

    // Object.prototype.toString.call() 不仅可以判断出简单数据类型 复杂数据类型   正则  日期对象








</script>
</html>